formspec.o xmltag.o cet.o cet_util.o fatal.o rgbcolors.o \
inifile.o garmin_fs.o gbsleep.o units.o @GBSER@ gbser.o \
gbfile.o parse.o session.o src/core/xmlstreamwriter.o \
+ src/core/usasciicodec.o \
$(PALM_DB) $(GARMIN) $(JEEPS) $(SHAPE) @ZLIB@ $(FMTS) $(FILTERS)
OBJS = main.o globals.o $(LIBOBJS) @FILEINFO@
cet.h cet_util.h inifile.h session.h src/core/datetime.h
cet_util.o: cet_util.cc defs.h config.h queue.h zlib/zlib.h zlib/zconf.h \
gbfile.h cet.h cet_util.h inifile.h session.h src/core/datetime.h \
- cet/ansi_x3_4_1968.h cet/cp1252.h
+ cet/ansi_x3_4_1968.h cet/cp1252.h cet/iso_8859_8.h
compegps.o: compegps.cc defs.h config.h queue.h zlib/zlib.h zlib/zconf.h \
gbfile.h cet.h cet_util.h inifile.h session.h src/core/datetime.h \
csv_util.h jeeps/gpsmath.h jeeps/gpsport.h
cet.h cet_util.h inifile.h session.h src/core/datetime.h strptime.h
csv_util.o: csv_util.cc defs.h config.h queue.h zlib/zlib.h zlib/zconf.h \
gbfile.h cet.h cet_util.h inifile.h session.h src/core/datetime.h \
- csv_util.h grtcirc.h strptime.h jeeps/gpsmath.h jeeps/gpsport.h \
- garmin_fs.h jeeps/gps.h jeeps/gpsdevice.h jeeps/gpssend.h \
- jeeps/gpsread.h jeeps/gpsutil.h jeeps/gpsapp.h jeeps/gpsprot.h \
- jeeps/gpscom.h jeeps/gpsfmt.h jeeps/gpsmem.h jeeps/gpsrqst.h \
- jeeps/gpsinput.h jeeps/gpsproj.h xcsv_tokens.gperf
+ csv_util.h garmin_fs.h jeeps/gps.h jeeps/gpsport.h jeeps/gpsdevice.h \
+ jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h jeeps/gpsapp.h \
+ jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h jeeps/gpsmath.h \
+ jeeps/gpsmem.h jeeps/gpsrqst.h jeeps/gpsinput.h jeeps/gpsproj.h \
+ grtcirc.h src/core/logging.h strptime.h xcsv_tokens.gperf
delbin.o: delbin.cc defs.h config.h queue.h zlib/zlib.h zlib/zconf.h \
gbfile.h cet.h cet_util.h inifile.h session.h src/core/datetime.h \
src/core/xmltag.h
magellan.h gbser.h explorist_ini.h
main.o: main.cc defs.h config.h queue.h zlib/zlib.h zlib/zconf.h gbfile.h \
cet.h cet_util.h inifile.h session.h src/core/datetime.h filterdefs.h \
- csv_util.h
+ csv_util.h src/core/usasciicodec.h
mapasia.o: mapasia.cc defs.h config.h queue.h zlib/zlib.h zlib/zconf.h \
gbfile.h cet.h cet_util.h inifile.h session.h src/core/datetime.h
mapbar_track.o: mapbar_track.cc defs.h config.h queue.h zlib/zlib.h \
filterdefs.h grtcirc.h
sort.o: sort.cc defs.h config.h queue.h zlib/zlib.h zlib/zconf.h gbfile.h \
cet.h cet_util.h inifile.h session.h src/core/datetime.h filterdefs.h
+src/core/usasciicodec.o: src/core/usasciicodec.cc src/core/usasciicodec.h
src/core/xmlstreamwriter.o: src/core/xmlstreamwriter.cc \
src/core/xmlstreamwriter.h
stackfilter.o: stackfilter.cc defs.h config.h queue.h zlib/zlib.h \
#include "csv_util.h"
#include "inifile.h"
#include "session.h"
+#include "src/core/usasciicodec.h"
#include <ctype.h>
#include <signal.h>
} arg_stack_t;
static arg_stack_t
-*push_args(arg_stack_t* stack, const int argn, const int argc, char* argv[])
+* push_args(arg_stack_t* stack, const int argn, const int argc, char* argv[])
{
arg_stack_t* res = (arg_stack_t*) xmalloc(sizeof(*res));
}
static arg_stack_t
-*pop_args(arg_stack_t* stack, int* argn, int* argc, char** argv[])
+* pop_args(arg_stack_t* stack, int* argn, int* argc, char** argv[])
{
arg_stack_t* res;
char** argv2 = *argv;
queue* wpt_head_bak, *rte_head_bak, *trk_head_bak; /* #ifdef UTF8_SUPPORT */
signed int wpt_ct_bak, rte_ct_bak, trk_ct_bak; /* #ifdef UTF8_SUPPORT */
arg_stack_t* arg_stack = NULL;
+ (void) new gpsbabel::UsAsciiCodec(); /* make sure a US-ASCII codec is available */
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
- // Qt 5.0 uses QString::fromUtf8 to convert from character pointers
- // and QBytreArrays to QStrings while previous version of Qt used
+ // Qt 5.0 uses QString::fromUtf8 to convert from character pointers
+ // and QBytreArrays to QStrings while previous version of Qt used
// QString::fromAscii. QString::fromAscii used the codec set
// by QTextCode::setCodecForCStrings.
// This makes the converstion consistent between Qt4 and Qt5.
}
switch (c) {
- //case 'c':
- // optarg = argv[argn][2] ? argv[argn]+2 : argv[++argn];
- // cet_convert_init(optarg, 1);
- // break;
+ //case 'c':
+ // optarg = argv[argn][2] ? argv[argn]+2 : argv[++argn];
+ // cet_convert_init(optarg, 1);
+ // break;
case 'i':
optarg = argv[argn][2]
? argv[argn]+2 : argv[++argn];
--- /dev/null
+/*
+ Copyright (C) 2014 Robert Lipe, gpsbabel.org
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
+
+ */
+
+#include "usasciicodec.h"
+#include <QtCore/QByteArray>
+#include <QtCore/QChar>
+#include <QtCore/QLatin1Char>
+#include <QtCore/QList>
+#include <QtCore/QString>
+
+// The availability of a US-ASCII codec is not promised by QTextCodec.
+// On Mac OS X is is likely one will not be available.
+// We provide our own to guarantee we have one.
+
+namespace gpsbabel
+{
+
+QByteArray UsAsciiCodec::name() const
+{
+ return "US-ASCII";
+}
+
+QList<QByteArray> UsAsciiCodec::aliases() const
+{
+ QList<QByteArray> list;
+ list += "iso-ir-6";
+ list += "ANSI_X3.4-1968";
+ list += "ANSI_X3.4-1986";
+ list += "ISO_646.irv:1991";
+ list += "ISO646-US";
+ list += "us";
+ list += "IBM367";
+ list += "cp367";
+ list += "csASCII";
+ return list;
+}
+
+int UsAsciiCodec::mibEnum() const
+{
+ return 3;
+}
+
+QString UsAsciiCodec::convertToUnicode(const char* chars, int len, ConverterState* state) const
+{
+ QString result(len, Qt::Uninitialized);
+ QChar* uc = result.data();
+ const unsigned char* c = (const unsigned char*)chars;
+ int invalid = 0;
+
+ for (int i = 0; i < len; i++) {
+ if (c[i] < 128) {
+ uc[i] = QLatin1Char(c[i]);
+ } else {
+ uc[i] = QChar::ReplacementCharacter;
+ ++invalid;
+ }
+ }
+
+ if (state) {
+ state->invalidChars += invalid;
+ state->remainingChars = 0;
+ }
+ return result;
+}
+
+QByteArray UsAsciiCodec::convertFromUnicode(const QChar* uc, int len, ConverterState* state) const
+{
+ QByteArray result(len, Qt::Uninitialized);
+ unsigned char* c = (unsigned char*)result.data();
+ const char replacement = (state && state->flags & ConvertInvalidToNull) ? 0 : '?';
+ int invalid = 0;
+ int u;
+
+ for (int i = 0; i < len; i++) {
+ u = uc[i].unicode();
+ if (u < 128) {
+ c[i] = (char) u;
+ } else {
+ c[i] = replacement;
+ ++invalid;
+ }
+ }
+
+ if (state) {
+ state->invalidChars += invalid;
+ state->remainingChars = 0;
+ }
+ return result;
+}
+
+} // namespace gpsbabel
--- /dev/null
+/*
+ Copyright (C) 2014 Robert Lipe, gpsbabel.org
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
+
+ */
+
+#ifndef QUSASCIICODEC_H
+#define QUSASCIICODEC_H
+
+#include <QtCore/QTextCodec>
+
+namespace gpsbabel
+{
+
+class UsAsciiCodec : public QTextCodec
+{
+public:
+ QByteArray name() const;
+ QList<QByteArray> aliases() const;
+ int mibEnum() const;
+ QString convertToUnicode(const char*, int, ConverterState*) const;
+ QByteArray convertFromUnicode(const QChar*, int, ConverterState*) const;
+};
+
+} // namespace gpsbabel
+#endif // QUSASCIICODEC_H